//
//  RW_HomeViewController.m
//  SleepApp
//
//  Created by MAC on 2021/3/19.
//  Copyright © 2021 RiceWang. All rights reserved.
//

#import "RW_HomeViewController.h"
#import "RW_AVAudioPlayerTools.h"
#import "RW_SingleModel.h"
#import "RW_HomeViewModel.h"

@interface RW_HomeViewController ()
@property (nonatomic,strong) UIButton *reload_button;
@property (nonatomic,strong) RW_HomeViewModel *wlclass_view_model;
@end

@implementation RW_HomeViewController
/** 初始化页面内容 */
- (void)initView{
    [super initView];
    [self.view addSubview:self.reload_button];
    [self.reload_button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).mas_offset(kNavBarAndStatusBarHeight + 5);
    }];
}
/** 子控制可以开始加载数据了 */
-(void)initData{
    self.reload_button.hidden = YES;
    [self.wlclass_view_model getNavcatSuccess:^(NSArray<WLNavigationScrollModel *> * _Nonnull response) {
        [self setNavigationScrollModelList:response];
    } fail:^(NSError * _Nonnull error) {
        self.reload_button.hidden = NO;
    }];
}

#pragma mark -- 父控制器功能

#pragma mark -- 懒加载
-(RW_HomeViewModel *)wlclass_view_model{
    if (!_wlclass_view_model){
        _wlclass_view_model = [[RW_HomeViewModel alloc]init];
    }
    return _wlclass_view_model;
}
-(UIButton *)reload_button{
    if (!_reload_button){
        _reload_button = [[UIButton alloc]init];
        [_reload_button setTitle:@"点击刷新页面数据" forState:UIControlStateNormal];
        [_reload_button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        _reload_button.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
        [_reload_button addTarget:self action:@selector(initData) forControlEvents:UIControlEventTouchUpInside];
        _reload_button.hidden = YES;
    }
    return _reload_button;
}
@end
